package com.example.xiaoshuo_yudu.mapper;

import com.example.xiaoshuo_yudu.entity.entity.Bookshelf;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 用户书架表 Mapper 接口
 * </p>
 *
 * @author xusen
 * @since 2025-07-31
 */
@Mapper
public interface BookshelfMapper extends BaseMapper<Bookshelf> {
//    @Select("select * from bookshelf where book_id = #{bookId}")
//    boolean selectByBookId(Long bookId);
    @Select("select * from bookshelf where user_id = #{userId} and book_id = #{bookId} ")
    Bookshelf selectByUserAndBook(Long userId, Long bookId);
    @Select("select * from bookshelf where user_id = #{userId} and is_bookshelf=0")
    List<Bookshelf> getBookshelf(Long userId);
    @Select("select * from bookshelf where user_id = #{userId} ")
    List<Bookshelf> getBookreading(Long userId);

    int updateIsBookshelfByIdsAndUserId(List<Long> ids, Long userId);

    int deleteReadingBooks(List<Long> ids, Long userId);
}
